<?php
class mysqlDao
{
    private $m_db;

    public function __construct($strHost, $strUserName, $strPassWord, $strDatabase)
    {
        $this->m_db = new mysqli($strHost, $strUserName, $strPassWord, $strDatabase);
        if (mysqli_connect_errno())
        {
            throw "Error: Could not connect to database. Please try again later.";
        }
    }
    public function __destruct()
    {
        $this->m_db->close();
    }

    public function getList($strSQL)
    {
        $result_list = array();
        if (false === $this->m_db->real_query($strSQL))
        {
            echo mysqli_error($this->m_db)."\n";
            return false;
        }
        else
        {
            if ($result = $this->m_db->use_result()) {
                while ($row = $result->fetch_row()) {
                    $result_list[] = $row;
                }
                var_dump($result_list);
                $result->close();
            }
        }
        return $result_list;
    }

    public function getSingleRow($strSQL)
    {
        $result_row = false;
        if (false === $this->m_db->real_query($strSQL))
        {
            echo mysqli_error($this->m_db)."\n";
            return false;
        }
        else
        {
            if ($result = $this->m_db->use_result()) {
                $result_row = $result->fetch_row();
                var_dump($result_row);
                $result->close();
            }
        }
        return $result_row;
    }
};
?>
